package su.mvc.util;

import com.googlecode.objectify.Key;
import ognl.DefaultTypeConverter;

import java.util.Map;


public class KeyConverter extends DefaultTypeConverter {

    public Object convertValue(Map map, Object o, Class toType) {
        if (toType == Key.class) {
            String s = ((String[]) o)[0];
            return Key.create(s);
        } else if (toType == String.class) {
            Key k = (Key) o;
            return k.getString();
        }

        return null;
    }

}
